package ahblue.cn.tanzi.view;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.webkit.WebView;

public class MyWebView extends WebView {
    public MyWebView(Context context) {
        super(context);
    }

    public MyWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (onDrawAfterListener != null){
            onDrawAfterListener.onDrawAfter();
        }
    }

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        heightMeasureSpec = MeasureSpec.makeMeasureSpec(
                Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    public interface OnDrawAfterListener{
        void onDrawAfter();
    }

    private OnDrawAfterListener onDrawAfterListener;
    public void setOnDrawAfterListener(OnDrawAfterListener onDrawAfterListener){
        this.onDrawAfterListener = onDrawAfterListener;
    }
}
